/*
 * @Author: qinuoyun
 * @Date:   2019-08-27 10:10:32
 * @Last Modified by:   Slience
 * @Last Modified time: 2019-09-30 00:01:30
 */

/**
 * [alert description]
 * @action       {String}    弹窗按钮
 * @content      {String}    弹窗内容
 */
let alert_form = {
  title: 'alert弹出框',
  width: '40%',
  components:'form',
  action: [{
    type: 'primary',
    label: '确定发货',
    icon: '',
    callback: {
      type:'submit',
      url: ['goods', 'on_goods_edit'],
    }
  }, {
    type: 'default',
    label: '取消发货',
    icon: '',
  }],
  content: [{
    label: "物流编号",
    type: "input",
    field: "goods_sn",
    labelWidth: "120",
    placeholder: "输入物流编号",
    span: 6
  }, {
    label: "物流名称",
    type: "select",
    field: "goods_name",
    labelWidth: "120",
    placeholder: "选择物流名称",
    span: 6,
    option:[],
    group:{
        label:'group_name',
        value:'group_id'
    },
    url:['goods','get_goods_group'],
  }]
}


let alert_table = {
  title:'详情单',
  width:'50%',
  components:"table",
  action:[{
    type: 'primary',
    label: '确定发货',
    icon: '',
  }, {
    type: 'default',
    label: '取消发货',
    icon: '',
  }],
  content:[{
    label: "商品编号",
    type: "input",
    field: "goods_sn",
    // labelWidth: "120",
    sortable: true,
  },
  {
    label: "商品名称",
    type: "input",
    field: "goods_name",
    // labelWidth: "120",
    sortable: true,
    amend: true,
    params: ['goods_id'],
  }, {
    label: "商品价格",
    type: "input",
    field: "goods_price",
    // labelWidth: "120",
    sortable: false,
    amend: true,
    params: ['goods_id'],
  }, {
    label: "封面",
    type: "image",
    field: "goods_cover",
    // labelWidth: "180",
    sortable: false,
  }]
}



var config = {

  /**
   * 增删改查，api地址
   * @total 获取总条数api
   * @get   获取数据api
   * @edit  修改数据api
   *
   * model        类名
   * action       方法名 
   */
  set_url: {
    "total": { model: "goods", action: "get_goods_total" },
    "get": { model: "goods", action: "get_goods_all" },
    "edit": { model: "goods", action: "on_goods_edit" }
  },

  /**
   * 筛选查询
   * level 外层分组
   *   @label       {String}   标签
   *   @type        {String}   类型
   *   @field       {String}   字段
   *   @labelWidth  {String}   标签宽度
   *   @placeholder {String}   提示信息
   *   @span        {Number}   显示格数
   */
  select: [
    [{
      label: "商品名称",
      type: "input",
      field: "goods_name",
      labelWidth: "120",
      placeholder: "选择",
      span: 6
    }, {
      label: "商品编码",
      type: "input",
      field: "goods_sn",
      labelWidth: "120",
      placeholder: "选择",
      span: 6
    }, {
      label: "是否删除",
      field: "is_delete",
      hide: true,
      value: 1
    }],
    // {
    //   label:"高级搜索",
    //   config:[
    //     [{
    //       label: "商品名称",
    //       type: "input",
    //       field: "goods_name",
    //       labelWidth: "120",
    //       placeholder: "选择",
    //       span: 12
    //     },{
    //       label: "商品编码",
    //       type: "input",
    //       field: "goods_sn",
    //       labelWidth: "120",
    //       placeholder: "选择",
    //       span: 12
    //     }]
    //   ]
    // }
  ],
  /**
   * 分页查询
   * @size    {Number}  分页数目
   * @current {Number}  当前页数
   * total    {number}  总条目数
   */
  page: {
    size: 5,
    current: 1,
    total: 100
  },
  tips: {
    title: "小助手提醒您",
    body: "列表[产品价格],[虚拟销量],[库存]可进行快速修改,双击或者单击进入编辑模式,失去焦点可进行自动保存"
  },


  /**
   * 表格批量功能
   * @type {Array}
   */
  action:[{
    label:"保存",
    type:"primary",
    icon:"",
    callback:{
      type:"default",
      url:['goods','on_goods_edit'],
      confirmTips: {
        type: 'success',
        message: '更新成功！',
      },
      cancelTips: {
        type: 'info',
        message: '您取消了更新！',
      }
    }
  },{
    label: "批量删除",
    callback: {
      type: 'message',
      url: ['goods', 'on_goods_delete'],
      params: ['goods_id'],
      config: {
        type: 'warning',
        title: '系统提示',
        content: '此操作将永久删除删除文件不可恢复，是否继续！',
        confirm: '继续',
        cancel: '取消',
        confirmTips: {
          type: 'success',
          message: '删除成功！',
        },
        cancelTips: {
          type: 'info',
          message: '您取消了删除！',
        }
      }
    },
    type: "primary",
    icon: "",
  },{
    label: "发布",
    callback: {
      type: '',
      path: 'goods_fix',
      params: ['goods_id', 'goods_sn']
    },
    type: "default",
    icon: "el-icon-search",
  }],
  /**
   * [table description]
   * @selection   {Boolean}   是否开启多选
   * @model       {String}    表格模式  popover:对话框修改    input:直接在单元格中修改
   * @label       {String}    标签
   * @type        {String}    类型
   * @field       {String}    字段
   * @option      {Array}     数据选项
   * @labelWidth  {String}    标签宽度
   * @sortable    {String}    是否排序
   * @amend       {Boolean}   是否直接修改   
   * @tips        {Boolean}   是否添加头部说明
   * @headTips    {Object}    头部提示内容  tips:true  方才有效
   * @filters     {Array}     表头筛选功能
   */
  selection:true,
  model:'input',
  table:[{
    label: "商品编号",
    type: "input",
    field: "goods_sn",
    labelWidth: "120",
    sortable: true,
  },{
    label: "商品库存",
    type: "input",
    field: "goods_repertory",
    // labelWidth: "120",
    amend: true,
    tips:true,
    params: ['goods_id'],
    option: [{
      label: "发货",
      value: 1
    }],
    sortable: false,
  }, 
  
  {
    label: "商品名称",
    type: "input",
    field: "goods_name",
    labelWidth: "180",
    sortable: true,
    tips:true,
    headTips:'商品名称',
    amend: true,
    params: ['goods_id'],
    filters:[{
      text:"售罄",
      value:"售罄",
    },{
      text:"油桃",
      value:"油桃",
    }]
  }, {
    label: "商品价格",
    type: "input",
    field: "goods_price",
    labelWidth: "120",
    sortable: false,
    tips:true,
    headTips:'商品价格说明',
    amend: true,
    params: ['goods_id'],
  }, {
    label: "商品库存",
    type: "input",
    field: "goods_repertory",
    // labelWidth: "120",
    amend: true,
    tips:true,
    params: ['goods_id'],
    option: [{
      label: "发货",
      value: 1
    }],
    sortable: false,
  }, {
    label: "封面",
    type: "image",
    field: "goods_cover",
    labelWidth: "180",
    sortable: false,
  }, {
    label: "开关",
    type:"switch",
    field:'switch',
    params:['goods_id'],
    labelWidth:'180',
    sortable:false,
    option:{
      disabled:false,
      activeColor:"#ff00ff",
      inactiveColor:"#ff4949",
      // activeIcon:"el-icon-edit",
      // inactiveIcon:"el-icon-delete",
      activeText:"开启",
      inactiveText:"关闭",
    }
  }, {
    label: "操作",
    type: "action",
    field: "action",
    labelWidth:"400",
    option: [{
      label: "删除",
      callback: {
        type: 'message',
        url: ['goods', 'on_goods_delete'],
        params: ['goods_id'],
        config: {
          type: 'warning',
          title: '系统提示',
          content: '此操作将永久删除删除文件不可恢复，是否继续！',
          confirm: '继续',
          cancel: '取消',
          confirmTips: {
            type: 'success',
            message: '删除成功！',
          },
          cancelTips: {
            type: 'info',
            message: '您取消了删除！',
          }
        }
      },
      type: "primary",
      icon: "",
    }, {
      label: "发货",
      callback: {
        type: "alert",
        rule: [{
          field: "order_status",
          equality: " == 1"
        }],
        config: alert_form
      },
      type: "primary",
      icon: "",
    }, {
      label: "修改",
      callback: {
        type: 'target',
        path: 'goods_fix',
        params: ['goods_id', 'goods_sn']
      },
      type: "primary",
      icon: "",
    }, {
      label: "查看",
      callback: {
        type:"alert",
        config:alert_table
      },
      type: "primary",
      icon: "",
    }],
    sortable: false,
  }
]
}
export default config;
